<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=no">
    <title>日新网 - 问答支付</title>
</head>
<body>
<tc_include file="scripts"/>
<script src="__PUBLIC__/js/layer/layer_1.js"></script>
<script>
    function jsApiCall()
    {
        WeixinJSBridge.invoke('getBrandWCPayRequest', {$parameters}, function(res){
            if(res.err_msg == "get_brand_wcpay_request:ok" ){
                // 使用以上方式判断前端返回,微信团队郑重提示：
                //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                window.location.href = "{:U('Question/Question/question_info', ['id' => $question_id])}";
            } else {
                layer.msg('支付失败');
            }
        });
    }

    function callpay()
    {
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }else{
            jsApiCall();
        }
    }
    $(document).ready(function () {
        callpay();
    });
</script>
</body>
</html>